﻿@model ARchGL.Declaration.Platform.Service.Dtos.ProjectDto
<div class="page-bar">
    <ul class="page-breadcrumb">
        <li>
            <span id="module">系统管理员</span>
            <i class="fa fa-angle-right"></i>
        </li>
        <li>
            <span id="action"></span>
        </li>
    </ul>
</div>
<!-- END PAGE BAR -->
<div class="mt-bootstrap-tables" style="margin-top:20px">
    <div class="row">
        <div class="col-md-12">
            <div class="portlet light bordered">
                <div class="portlet-title">
                    <div class="caption">
                        <i class="icon-social-dribbble font-green hide"></i>
                    </div>
                    <div class="actions">
                        <a class="btn btn-default" href="@Url.Action("Index")">
                            <i class="fa fa-plus"></i> 列表
                        </a>
                    </div>
                </div>

                <div class="portlet-body form">
                    <!-- BEGIN FORM-->
                    <form id="defaultForm" class="form-horizontal" method="post" action="@Url.Action("Edit")">
                        <div class="form-body">
                            <div class="row">
                                <div class="col-md-6">
                                    <div class="form-group">
                                        <label class="control-label col-md-3">
                                            帐号：
                                            <span class="required" aria-required="true">*</span>
                                        </label>
                                        <div class="col-md-9">
                                            <div class="input-icon right">
                                                <i class="fa"></i>
                                                @Html.HiddenFor(x => x.Id)
                                                @Html.TextBoxFor(x => x.CategoryLevel3, new { @class = "form-control", @maxlength = "50", @placeholder = "不能为空，长度50", @required = "required" })
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                            <div class="row">
                                <div class="col-md-6">
                                    <div class="form-group">
                                        <label class="control-label col-md-3">
                                            密码：
                                            <span class="required" aria-required="true">*</span>
                                        </label>
                                        <div class="col-md-9" id="lecturerDiv">
                                            <div class="input-icon right">
                                                <i class="fa"></i>
                                                @Html.PasswordFor(x => x.CategoryLevel1, new { @class = "form-control", @maxlength = "50", @placeholder = "不能为空", @required = "required" })
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                            <div class="form-actions">
                                <div class="row">
                                    <div class="col-md-offset-3 col-md-9">
                                        <button type="submit" class="btn green">保存</button>
                                        <button type="reset" class="btn">重置</button>
                                    </div>
                                </div>
                            </div>
                    </form>
                    <!-- END FORM-->
                </div>
            </div>
        </div>
    </div>
</div>
@section scripts{
    <script type="text/javascript">
        var opIndexColumns = function (value, row, index) {
            return index + 1;
        };
        var opColumns = function (value, row, index) {
            if (row.IsSuperAdmin) {
                return "-";
            }
            else if (row.EnabledMark == null || row.EnabledMark) {
                return ("<a href=\"@Url.Action("Edit")?memberid=_id_\">编辑</a> | <a href=\"@Url.Action("Assignment")?memberid=_id_\">角色</a> | <a href=\"javascript:_updateState('_id_'," + false + ");\">" + "禁用" + "</a>").replace(/_id_/ig, row.Id).replace(/_name_/ig, encodeURI(row.Account));

            } else if (!row.EnabledMark) {
                return ("<a href=\"@Url.Action("Edit")?memberid=_id_\">编辑</a> | <a href=\"@Url.Action("Assignment")?memberid=_id_\">角色</a> | <a href=\"javascript:_updateState('_id_'," + true + ");\">" + "启用" + "</a> | <a href=\"javascript:_delte('_id_');\">删除</a>").replace(/_id_/ig, row.Id).replace(/_name_/ig, encodeURI(row.Account));

            }

        };

        customFormValidate($("#defaultForm"), {
            Account: {
                remote: {
                    type: 'POST',
                    url: '@Url.Action("IsExisted")',
                    data: {
                        Account: $("input[name='Account']", formDoc).val(),
                        Id: $("input[name='Id']", formDoc).val()
                    }
                }
            }
        }, function (form) {
            var data = $(form).serializeObject();
            $.ajax({
                type: "POST",
                url: "@Url.Action("Save")",
                data: data,
                async: false,
                success: function (reslut) {
                    if (reslut.Success) {
                        showToast(0, '系统提示', "保存成功");
                        setTimeout(function () {
                            location.href = "@Url.Action("Index")";
                        }, 500);
                    } else {
                        showToast(3, '系统提示', reslut.Message);
                    }
                },
                error: function (error) {
                    showToast(3, '系统提示', " 操作失败!");
                }
            });
        });
    </script>

}